import android.app.Activity;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;

import com.kwai.auth.ILoginListener;
import com.kwai.auth.KwaiAuthAPI;
import com.kwai.auth.common.InternalResponse;
import com.kwai.auth.common.KwaiConstants;
import com.kwai.auth.login.kwailogin.KwaiAuthRequest;

public class Kuaishou {

    final ILoginListener loginListener = new ILoginListener() {
        @Override
        public void onSuccess(@NonNull InternalResponse response) {
            // 根据授权返回的code请求openId(详细可以参考demo)。为了安全性，建议放在第三方的服务器中，由接入方服务器实现这个请求接口后将openid返回接入方的客户端。
            Log.e("快手授权","成功");

        }

        @Override
        public void onFailed(String state, int errCode, String errMsg) {
            Log.e("快手授权","失败");
        }

        @Override
        public void onCancel() {
            Log.e("快手授权","关闭");
        }
    };




    public void mifnsf(Activity activity){
        KwaiAuthRequest request = new KwaiAuthRequest.Builder()
                .setState("state_str")
                .setRequiredScopes("user_info")// 必选权限，授权页无法手动取消勾选
                .setAuthMode(KwaiConstants.AuthMode.AUTHORIZE)
                .setLoginType(KwaiConstants.LoginType.APP)
                .setPlatformArray(new String[]{KwaiConstants.Platform.KWAI_APP,KwaiConstants.Platform.NEBULA_APP})
                .build();
        KwaiAuthAPI.getInstance().sendRequest(activity, request, this.loginListener);

    }
}
